package org.groovymud.scripting.domain;

import java.util.Arrays;
import java.util.List;

import org.groovymud.config.MudConfig;
import org.groovymud.scripting.utils.BindingDelegate;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class AbstractSuffixedScriptedDomainManager<T> implements DomainManager<T> {

	private BindingDelegate bindingDelegate;
	private final List<String> domainSuffixe;

    public AbstractSuffixedScriptedDomainManager(BindingDelegate bindingDelegate, String... domainSuffixe) {
        this.domainSuffixe = Arrays.asList(domainSuffixe);
        this.bindingDelegate = bindingDelegate;
    }

    public boolean matchesSuffixe(String domain) {
		for (String suffix : domainSuffixe) {
			if (domain.endsWith(suffix)) {
				return true;
			}
		}
		return false;
	}

	/**
	 * @return the domainSuffixe
	 */
	public List<String> getDomainSuffixe() {
		return domainSuffixe;
	}

	/**
	 * @return the bindingDelegate
	 */
	public BindingDelegate getBindingDelegate() {
		return bindingDelegate;
	}

}
